import Vue from 'vue'
import Vuex from 'vuex'
// 引入封装好的axios
import axios from '@/api/http.js'
// 引入接口
import url from '../api/url.js'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    // 分类页请求id
    classifyList: {},
    // 底部导航是否显示
    fotShow: true
  },
  mutations: {
    // 修改state中classifyList数据
    changClissifyList (state, data) {
      state.classifyList = data
    },
    // 修改底部导航fotShow
    setFotShow (state, bol) {
      state.fotShow = bol
    }
  },
  actions: { // 异步操作 必须要提交到mutations中
    // 获取classify页面数据
    getClassifyList (store, id) {
      axios.get(url.getClassifyInfo + id)
        .then((res) => {
          store.commit('changClissifyList', res.data)
        })
    }
  },
  modules: {
  }
})
